<template>
  <view>
    <view class="bg-color" />
    <my-custom bgColor="bg-gradual-blue" :isBack="false">
      <block slot="content">我的</block>
    </my-custom>
    我的
    <view>用户Id：{{ user.userId }}</view>
    <view>姓名：{{ user.username }}</view>
    <view>手机号：{{ user.phoneNumber }}</view>
    <button @tap="logout">注销</button>
    <my-component-tabar />
  </view>
</template>

<script>
import * as auth from "@/api/auth.js";
export default {
  data() {
    return {
      user: {},
    };
  },
  onShow(option) {
    auth.currentUser().then((res) => {
      console.log(res.data);
      this.user = res.data;
    });
  },
  methods: {
    logout() {
      // 调用登录接口
        // auth.logout();
      // 清除token：lifeData
      uni.setStorageSync("lifeData", "");
      // 跳转到登录界面
      uni.navigateTo({
        url: "../login/login/index",
      });
    },
  },
};
</script>

<style>
.bg-color {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #f7f7f7;
  z-index: -1;
}
</style>
